"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
const tiny_entity2_1 = require("tiny-entity2");
const EntityObjectType = tiny_entity2_1.EntityObjectFactory.GetEntityObjectType(process.env.dataBaseType || 'mysql');
const account_1 = require("./account");
let User = class User extends EntityObjectType {
};
__decorate([
    tiny_entity2_1.Define.PrimaryKey(),
    __metadata("design:type", String)
], User.prototype, "id", void 0);
__decorate([
    tiny_entity2_1.Define.Column({ DataType: tiny_entity2_1.Define.DataType.VARCHAR, NotAllowNULL: true }),
    __metadata("design:type", String)
], User.prototype, "nickName", void 0);
__decorate([
    tiny_entity2_1.Define.Column({ DataType: tiny_entity2_1.Define.DataType.VARCHAR, NotAllowNULL: true }),
    __metadata("design:type", String)
], User.prototype, "phone", void 0);
__decorate([
    tiny_entity2_1.Define.Column({ DataType: tiny_entity2_1.Define.DataType.INT, DataLength: 11 }),
    __metadata("design:type", Number)
], User.prototype, "gender", void 0);
__decorate([
    tiny_entity2_1.Define.Column({
        DataType: tiny_entity2_1.Define.DataType.VARCHAR,
        IsIndex: true,
        NotAllowNULL: true
    }),
    __metadata("design:type", String)
], User.prototype, "accountId", void 0);
__decorate([
    tiny_entity2_1.Define.Column({
        DataType: tiny_entity2_1.Define.DataType.VARCHAR,
        NotAllowNULL: true,
        IsIndex: true
    }),
    __metadata("design:type", String)
], User.prototype, "storeId", void 0);
__decorate([
    tiny_entity2_1.Define.Column({
        DataType: tiny_entity2_1.Define.DataType.INT,
        DataLength: 2,
        DefaultValue: 0
    }),
    __metadata("design:type", Number)
], User.prototype, "status", void 0);
__decorate([
    tiny_entity2_1.Define.Mapping({
        Mapping: 'Account',
        MappingKey: { FKey: 'id', MKey: 'accountId' },
        MappingType: tiny_entity2_1.Define.MappingType.One
    }),
    __metadata("design:type", account_1.Account)
], User.prototype, "account", void 0);
__decorate([
    tiny_entity2_1.Define.Column({
        DataType: tiny_entity2_1.Define.DataType.BIGINT,
        NotAllowNULL: true
    }),
    __metadata("design:type", Number)
], User.prototype, "createTime", void 0);
__decorate([
    tiny_entity2_1.Define.Column({
        DataType: tiny_entity2_1.Define.DataType.VARCHAR
    }),
    __metadata("design:type", String)
], User.prototype, "type", void 0);
__decorate([
    tiny_entity2_1.Define.Column({
        DataType: tiny_entity2_1.Define.DataType.BIGINT
    }),
    __metadata("design:type", Number)
], User.prototype, "version", void 0);
__decorate([
    tiny_entity2_1.Define.Mapping({
        Mapping: 'ImageStore',
        MappingKey: { FKey: 'objectId', MKey: 'id' }
    }),
    __metadata("design:type", Array)
], User.prototype, "images", void 0);
__decorate([
    tiny_entity2_1.Define.Mapping({
        Mapping: 'AccountRoles',
        MappingKey: { FKey: 'accountId', MKey: 'accountId' }
    }),
    __metadata("design:type", Array)
], User.prototype, "accountRoles", void 0);
User = __decorate([
    tiny_entity2_1.Define.Table({ TableName: "user" })
], User);
exports.User = User;
class UserStatus {
    constructor(name, value) {
        this.name = name;
        this.value = value;
    }
    get Name() { return this.name; }
    get Value() { return this.value; }
    static Prase(value) {
        switch (value) {
            case 0: return UserStatus.Normal;
            case 1: return UserStatus.Disable;
            default: throw new Error('not allowed UserStatus value.');
        }
    }
}
UserStatus.Normal = new UserStatus('normal', 0);
UserStatus.Disable = new UserStatus('disable', 1);
exports.UserStatus = UserStatus;
exports.UserType = {
    Employee: 'employee',
    Owner: 'owner'
};
